package com.briup.jz.web.controller;

import java.util.List;
import javax.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.briup.jz.bean.BaseLog;
import com.briup.jz.bean.Carousel;
import com.briup.jz.service.IBaseLogService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description="日志相关接口")
@Validated
@RestController
@RequestMapping("/baselog")
public class BaseLogController {
	  @Autowired
	    private IBaseLogService baselogService;
	  @ApiOperation(value = "通过realname查询所有日志分类")
	    @GetMapping("pagequery")
	    public Message pagequery(String realname){
	        List<BaseLog> list = baselogService.query(realname);
	        return MessageUtil.success(list);
	    }
	  
	  @ApiOperation(value = "保存或更新日志信息")
	  @ApiImplicitParams({
	          @ApiImplicitParam(name="id",value = "主键",paramType = "query"),
	          @ApiImplicitParam(name="realname",value = "名称",paramType = "query",required = true),
	          @ApiImplicitParam(name="method",value = "方法",paramType = "query"),
	          @ApiImplicitParam(name="logTime",value = "时间",paramType = "query"),
	         
	  })
	  @PostMapping("saveOrUpdate")
	  public Message saveOrUpdate(BaseLog baselog){
	      baselogService.saveOrUpdate(baselog);
	      return MessageUtil.success("更新成功");
	  }
	  @ApiOperation(value = "通过id删除")
	  @GetMapping("deleteById")
	  @ApiImplicitParams({
	      @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
	  })
	  public Message deleteById(@NotNull long id){
	      baselogService.deleteById(id);
	      return MessageUtil.success("删除成功");
	  }


}
